﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace Org.Eurekaa.DNJ.UI.Design.Editors
{
    public partial class CodeEditor : Form
    {
        public CodeEditor()
        {
            InitializeComponent();
        }
        public string Value
        {
            get { return m_syntaxRichTextBox.Text; }
            set { m_syntaxRichTextBox.Text = value; m_syntaxRichTextBox.ProcessAllLines(); }
        }

        private void CodeEditor_Load(object sender, EventArgs e)
        {
            m_syntaxRichTextBox.Width = this.Width - 40;
            string keywords = "$|abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default delete|do|double|else|enum|export|extends|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|try|typeof|var|void|volatile|while|with|true|false|prototype";
            ArrayList keylist = new ArrayList(keywords.Split(new char[] { '|' }));

            foreach (string kw in keylist)
                m_syntaxRichTextBox.Settings.Keywords.Add(kw);

            // Set the comment identifier. For Lua this is two minus-signs after each other (--). 
            // For C++ we would set this property to "//".
            m_syntaxRichTextBox.Settings.Comment = "//";

            // Set the colors that will be used.
            m_syntaxRichTextBox.Settings.KeywordColor = Color.Blue;
            m_syntaxRichTextBox.Settings.CommentColor = Color.Green;
            m_syntaxRichTextBox.Settings.StringColor = Color.Gray;
            m_syntaxRichTextBox.Settings.IntegerColor = Color.Red;

            // Let's not process strings and integers.
            m_syntaxRichTextBox.Settings.EnableStrings = true;
            m_syntaxRichTextBox.Settings.EnableIntegers = true;

            // Let's make the settings we just set valid by compiling
            // the keywords to a regular expression.
            m_syntaxRichTextBox.CompileKeywords();
            m_syntaxRichTextBox.ProcessAllLines();
        }

        private void btnSend_Click(object sender, EventArgs e)
        {

        }
    }
}
